#ifndef PSC_SERVER_H_
#define PSC_SERVER_H_
#include "iec61850_server.h"
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <linux/un.h>
#include <sys/time.h>
#include <modbus.h>
#include "pcs_modbus_registers.h"

#define GOOSE_CB_ENABLE 0
#define REPORTING_ENABLE 1
#define SV_ENABLE 0
#define KEY_MAP_ENABLE 1
//需要root权限运行
#ifdef GOOSE_CB_ENABLE
#define GOOSE_ETH_INTERFACE "lo"
#define GOOSE_CB_REF "EVADASta/LLN0$GO$GcbValues"
#endif

#ifdef REPORTING_ENABLE
#define HOST_NAME "192.168.100.110"
#define TCP_PORT 10002
#define GOOSE_APPID 1000
#define DATASET_DIRECTORY "EVADASta/LLN0/ACStatus"
#define DATASET_REFERENCE "EVADASta/LLN0$ACStatus"
#define DATASET_RCB_REF "EVADASta/LLN0/RP/ACStatusEventsRCB01"
#define REPORT_RCB_REF  "EVADASta/LLN0$RP$ACStatusEventsRCB01"
#endif

#ifdef SV_ENABLE
#define SV_ETH_INTERFACE "lo"
#define SV_SAMPLE_LIMIT 4000
#define SV_TCP_PORT 10002
#define SVCBENABLE 1
#define SVID_NAME "ACSimulate"
#define SVCB_NAME "ACAnalog"
#define SV_CB_REF "EVADASta/LLN0.ACAnalog"
#endif
RegisterDesc* get_registerDesc(int addr, int flag);
void set_dataAttribute_range(DataAttribute* dataAttribute, float min, float max);
bool regMap_isExist(int addr);
bool regMap_search_byKey(int addr, int key, int *value);
bool regMap_search_byValue(int addr, int value, int *key);
void reg3553_process(int value);
void reg3513_process(int value);
#endif /* PSC_SERVER_H_ */

